Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #16822 #16884

Merged
merged 4 commits into from
Feb 1, 2021
Merged

fix #16822 #16884

merged 4 commits into from
Feb 1, 2021

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Jan 31, 2021

fix #16822
fix #14574
The kind of y may be nkHiddenAddr(so could be fixed by skipAddr too), so using x.type may be more correct.

@ringabout ringabout changed the title see whether it breaks fix #16822 Jan 31, 2021
@ringabout ringabout marked this pull request as ready for review January 31, 2021 10:27
tests/js/t16822.nim Outdated Show resolved Hide resolved
@timotheecour
Copy link
Member

@xflywind, awesome this also fixes #14574; please add these tests:

block: # bug #14574
  proc fn(): auto =
    let a = @[("foo", (12, 13))]
    for (k,v) in a:
      return (k,v)
  doAssert fn() == ("foo", (12, 13))

block: # bug #14574
  iterator fn[T](a:T): lent T = yield a
  let a = (10, (11,))
  proc bar(): auto =
    for (x,y) in fn(a):
      return (x,y)
  doAssert bar() == (10, (11,))

and change:

    when not defined(js): # pending https://github.com/nim-lang/Nim/issues/14574
      testRoundtrip({"z": (f1: 'f'), }.toTable): """{"z":{"f1":102}}"""

to

    # bug #14574
    testRoundtrip({"z": (f1: 'f'), }.toTable): """{"z":{"f1":102}}"""

in tests/stdlib/tjsonutils.nim

and add: "fix #14574" to your PR description so it auto-closes it

thanks!

@@ -1077,10 +1077,10 @@ proc genAsgnAux(p: PProc, x, y: PNode, noCopyNeeded: bool) =
# supports proc getF(): var T
if x.kind in {nkHiddenDeref, nkDerefExpr} and x[0].kind in nkCallKinds:
lineF(p, "nimCopy($1, $2, $3);$n",
[a.res, b.res, genTypeInfo(p, y.typ)])
[a.res, b.res, genTypeInfo(p, x.typ)])
Copy link
Member

@timotheecour timotheecour Feb 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does

lineF(p, "$1 = nimCopy(null, $2, $3);$n",
               [a.rdLoc, b.res, genTypeInfo(p, y.typ)])

a few lines above also need to change to y.typ => x.typ?
(I don't know which one is correct)

@Araq
Copy link
Member

Araq commented Feb 1, 2021

@timotheecour's remarks can be done later, merging this as it is because it's small and simple.

@Araq Araq merged commit de4f260 into nim-lang:devel Feb 1, 2021
ardek66 pushed a commit to ardek66/Nim that referenced this pull request Mar 26, 2021
* see whether it breaks

* fix nim-lang#16884

* correct

* fix nim-lang#14574
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants